home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / QuickDraw GX / Programming Stuff / Sample Code / Printing Samples / Extensions… / Extension Shell multi-seg ƒ / Extension Seg2.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-06-14  |  2.7 KB  |  103 lines  |  [TEXT/MPS ]

  1. /*________________________________________________________
  2.  
  3.     File: Extension Seg2.c
  4.  
  5.     C code for a printing extension.
  6.  
  7.     Dave Hersey
  8.     Apple Developer Technical Support
  9.  
  10.     12/01/92 - dmh - Created.
  11.      4/26/93 - dmh - Updated to use recommended approach
  12.                       to global data initialization.
  13.      9/05/93 - dmh - Updated for b2.
  14.                     - Fixed minor problem with highlighting
  15.                      of editText panel items.
  16.                    - Switched to Exception.h assertion stuff
  17.                      for error checking.
  18.     12/18/93 - dmh - Updated for b3.
  19.      3/22/94 - dmh - Updated for b4.
  20.      6/10/94 - dmh - Added GXPRINTINGDISPATCH examples.
  21.      6/14/96 - cn  - Updated to support Universal Interfaces 2.1.
  22.  
  23.     (Note: all functions are in the Mark menu.)
  24.     
  25. __________________________________________________________*/
  26.  
  27. #define SECOND_SEG
  28. #include "Extension.h"
  29. #undef SECOND_SEG
  30.  
  31.  
  32. /*******************************************************************
  33.     SetUpPrintPanel sets up our print panel, adding a default
  34.     ExtensionCollection item to the job collection.  This
  35.     collection item has the values we'll use to set up our panel's
  36.     controls.
  37.     
  38. ********************************************************************/
  39.  
  40. OSErr SetUpPrintPanel()
  41. {
  42.     OSErr                    err;
  43.     gxPanelSetupRecord        panelSetupRec;
  44.     ExtensionCollection        extConfig;
  45.  
  46. // Try to find our collection item.
  47.  
  48.     err = GetCollectionItem(GXGetJobCollection(GXGetJob()),
  49.                             kExtensionCollectionType,
  50.                             gxPrintingTagID,
  51.                             nil,
  52.                             &extConfig);
  53.  
  54.  
  55. // If we don't have an item in the job collection yet, store our default
  56. // settings in it.
  57.  
  58.     if (err == collectionItemNotFoundErr)
  59.     {
  60.         extConfig.extTurnedOn = kDefaultSetting;
  61.     
  62.         err = AddCollectionItem(GXGetJobCollection(GXGetJob()),
  63.                                 kExtensionCollectionType,
  64.                                 gxPrintingTagID,
  65.                                 sizeof(ExtensionCollection),
  66.                                 &extConfig);
  67.  
  68.         nrequire(err, HaveCollectionMgrError);
  69.     }
  70.  
  71.  
  72. // Now, set up the panel.
  73.  
  74.     panelSetupRec.panelResId        = r_ExtensionPanel;        // which panel resource?
  75.     panelSetupRec.resourceRefNum    = GXGetMessageHandlerResFile(); // where is it?
  76.     panelSetupRec.refCon            = 0;                       // we don't use this.
  77.     panelSetupRec.panelKind            = gxExtensionPanel;     // This is an extension panel.
  78.  
  79.     err = GXSetupDialogPanel(&panelSetupRec);
  80.  
  81.  
  82. HaveCollectionMgrError:
  83.     
  84.     return err;
  85. }
  86.  
  87.  
  88. /*******************************************************************
  89.     GetJobCollectionItem is a generic routine that retrieves a
  90.     collection item from the job collection.
  91.     
  92. ********************************************************************/
  93.  
  94. OSErr GetJobCollectionItem(void *collectItem, long *collectSize,
  95.                            OSType collectType, short collectID)
  96. {
  97.     return GetCollectionItem(GXGetJobCollection(GXGetJob()),
  98.                              collectType,
  99.                              collectID,
  100.                              collectSize,
  101.                              collectItem);
  102. }
  103.